let userdasta: number = 123
userdasta = 2313
console.log(userdasta);

const arr: number[] =[1,2,3,4,5]
console.log(arr);

const arr1: ( number | string )[] = [1,2,3,4,'string']
console.log(arr1);


// 箭头函数
const Myfunction = (obj:number) => {
    console.log(obj)
    
}
Myfunction(1888)


// 普通的 function 函数
function add( a:number, b:number ){
    return a + b
}
console.log(add(3,4));


// 类型别名 type
type uniarry = ( number | string )[]
const arr2:uniarry = [1,2,3,'sting']
console.log(arr2)

const arr3:uniarry = [2,3,4,'mydata']
console.log(arr3)

// let timer: number | null = null
// timer = setTimeout(()=>{
//     console.log('时间到了喔');
    
// },1000)

const obj:{
    name: string,
    age: number,
    gender: string,
    hobby: string
}={
    name:'hahahha',
    age: 123,
    gender: '男',
    hobby: '打胶'
}

console.log(obj);

// type 声明对象的时候 需要加  ‘ = ’
// 属性直接需要加 ‘ ，’  
// 类似c语言的结构体
type myObj = {
    name: string,
    age: number,
    gender: string,
    hobby: string
}

const obj_1:myObj ={
    name: '6666',
    age: 6,
    gender: '公',
    hobby: '火龙果'
}
obj_1.age = 545
console.log(obj_1);


// interface 声明对类型的时候 不用加 ‘ = ’
// 并且 属性之间不用加 ‘ ， ’

interface Iperson {
    name: string
    age: number
    gender: string
    sayhi: () => void
}

const MING:Iperson = {
    name: 'Ming',
    age: 123,
    gender: 'male',
    sayhi: () => {
        console.log('HELLO, 我是小明')
    }
}

MING.sayhi()


// 继承
interface Istudents extends Iperson {
    store: number,
    Dohomework: () => void
}

const XiaoLI: Istudents = {
    name: '小李',
    age: 16,
    store: 99,
    gender: 'male',
    sayhi: ()=>{
        console.log('hello, 我是小李')
    },
    Dohomework: () => {
        console.log('我在做作业');        
    }
}

XiaoLI.sayhi()
XiaoLI.Dohomework()


